-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf: Introduce RcStr
#8221
Merged
Merged
perf: Introduce RcStr
#8221
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The latest updates on your projects. Learn more about Vercel for Git ↗︎
8 Ignored Deployments
|
🟢 Turbopack Benchmark CI successful 🟢Thanks |
|
✅ This change can build |
This was referenced May 28, 2024
bgw
approved these changes
Jun 5, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes since review LGTM, thanks!
kdy1
added a commit
to vercel/next.js
that referenced
this pull request
Jun 5, 2024
# Turbopack * vercel/turborepo#8272 <!-- Donny/강동윤 - feat: Update `swc_core` to `v0.92.8` --> * vercel/turborepo#8262 <!-- Alexander Lyon - add crate to calculate prehashes --> * vercel/turborepo#8174 <!-- Tobias Koppers - use prehash to avoid rehashing the key in the task cache --> * vercel/turborepo#7674 <!-- Alexander Lyon - [turbo trace] add ability to filter by value and occurences --> * vercel/turborepo#8287 <!-- Donny/강동윤 - feat: Update `swc_core` to `v0.92.10` --> * vercel/turborepo#8037 <!-- Alexander Lyon - create turbo-static for compile time graph analysis --> * vercel/turborepo#8293 <!-- Will Binns-Smith - Sync Cargo.lock with Next.js --> * vercel/turborepo#8239 <!-- Benjamin Woodruff - Reduce amount of code generated by ValueDebugFormat --> * vercel/turborepo#8304 <!-- Benjamin Woodruff - Minor optimizations to the codegen of TaskFnInputFunction --> * vercel/turborepo#8221 <!-- Donny/강동윤 - perf: Introduce `RcStr` --> ### What? I tried using `Arc<String>` in vercel/turborepo#7772, but a team member suggested creating a new type so we can replace underlying implementation easily in the future. ### Why? To reduce memory usage. ### How? Closes PACK-2776
ForsakenHarmony
pushed a commit
to vercel/next.js
that referenced
this pull request
Jul 25, 2024
### Description If we accept `: String` from a function, invoking the function needs one owned `String` and it means allocation even if the value isn't changed. But with this PR, functions now accept `RcStr`, which is shared, so invoking the same function with the same value does not involve allocation for `String` . --- I tried using `Arc<String>` in vercel/turborepo#7772, but a team member suggested creating a new type so we can replace underlying implementation easily in the future. I used `ast-grep` with ```yml id: convert-expr-into language: rust rule: kind: function_item all: - has: kind: parameters pattern: $PARAMS - any: - has: kind: visibility_modifier pattern: $VIS - not: has: kind: visibility_modifier - any: - has: kind: function_modifiers pattern: $MOD - not: has: kind: function_modifiers - has: field: return_type pattern: $RET - has: field: body pattern: $BODY - has: kind: identifier pattern: $NAME - follows: kind: attribute_item pattern: '#[turbo_tasks::function]' transform: NEW_PARAMS: replace: replace: 'String' by: 'RcStr' source: $PARAMS fix: $VIS $MOD fn $NAME $NEW_PARAMS -> $RET $BODY ``` ### Performance difference: #### `main`: ``` Benchmarking bench_startup/Next.js canary Turbo SSR/1000 modules: Warming up for 3.0000 s Warning: Unable to complete 10 samples in 60.0s. You may wish to increase target time to 65.6s. bench_startup/Next.js canary Turbo SSR/1000 modules time: [4.1476 s 4.1625 s 4.1752 s] Benchmarking bench_startup/Next.js canary Turbo RSC/1000 modules: Warming up for 3.0000 s Warning: Unable to complete 10 samples in 60.0s. You may wish to increase target time to 63.5s. bench_startup/Next.js canary Turbo RSC/1000 modules time: [4.0396 s 4.0673 s 4.0956 s] Benchmarking bench_startup/Next.js canary Turbo RCC/1000 modules: Warming up for 3.0000 s Warning: Unable to complete 10 samples in 60.0s. You may wish to increase target time to 69.7s. bench_startup/Next.js canary Turbo RCC/1000 modules time: [4.7222 s 4.7508 s 4.7790 s] ``` #### `pr`: ``` Benchmarking bench_startup/Next.js canary Turbo SSR/1000 modules: Warming up for 3.0000 s Warning: Unable to complete 10 samples in 60.0s. You may wish to increase target time to 66.2s. bench_startup/Next.js canary Turbo SSR/1000 modules time: [4.1175 s 4.1310 s 4.1496 s] Found 1 outliers among 10 measurements (10.00%) 1 (10.00%) high severe Benchmarking bench_startup/Next.js canary Turbo RSC/1000 modules: Warming up for 3.0000 s Warning: Unable to complete 10 samples in 60.0s. You may wish to increase target time to 63.7s. bench_startup/Next.js canary Turbo RSC/1000 modules time: [4.0401 s 4.0714 s 4.1105 s] Found 1 outliers among 10 measurements (10.00%) 1 (10.00%) high mild Benchmarking bench_startup/Next.js canary Turbo RCC/1000 modules: Warming up for 3.0000 s Warning: Unable to complete 10 samples in 60.0s. You may wish to increase target time to 70.2s. bench_startup/Next.js canary Turbo RCC/1000 modules time: [4.6696 s 4.6900 s 4.7107 s] Benchmarking bench_startup/Next.js 14 Turbo SSR/1000 modules: Warming up for 3.0000 s Warning: Unable to complete 10 samples in 60.0s. You may wish to increase target time to 63.9s. ``` --------- Co-authored-by: Benjamin Woodruff <benjamin.woodruff@vercel.com>
ForsakenHarmony
pushed a commit
to vercel/next.js
that referenced
this pull request
Jul 29, 2024
### Description If we accept `: String` from a function, invoking the function needs one owned `String` and it means allocation even if the value isn't changed. But with this PR, functions now accept `RcStr`, which is shared, so invoking the same function with the same value does not involve allocation for `String` . --- I tried using `Arc<String>` in vercel/turborepo#7772, but a team member suggested creating a new type so we can replace underlying implementation easily in the future. I used `ast-grep` with ```yml id: convert-expr-into language: rust rule: kind: function_item all: - has: kind: parameters pattern: $PARAMS - any: - has: kind: visibility_modifier pattern: $VIS - not: has: kind: visibility_modifier - any: - has: kind: function_modifiers pattern: $MOD - not: has: kind: function_modifiers - has: field: return_type pattern: $RET - has: field: body pattern: $BODY - has: kind: identifier pattern: $NAME - follows: kind: attribute_item pattern: '#[turbo_tasks::function]' transform: NEW_PARAMS: replace: replace: 'String' by: 'RcStr' source: $PARAMS fix: $VIS $MOD fn $NAME $NEW_PARAMS -> $RET $BODY ``` ### Performance difference: #### `main`: ``` Benchmarking bench_startup/Next.js canary Turbo SSR/1000 modules: Warming up for 3.0000 s Warning: Unable to complete 10 samples in 60.0s. You may wish to increase target time to 65.6s. bench_startup/Next.js canary Turbo SSR/1000 modules time: [4.1476 s 4.1625 s 4.1752 s] Benchmarking bench_startup/Next.js canary Turbo RSC/1000 modules: Warming up for 3.0000 s Warning: Unable to complete 10 samples in 60.0s. You may wish to increase target time to 63.5s. bench_startup/Next.js canary Turbo RSC/1000 modules time: [4.0396 s 4.0673 s 4.0956 s] Benchmarking bench_startup/Next.js canary Turbo RCC/1000 modules: Warming up for 3.0000 s Warning: Unable to complete 10 samples in 60.0s. You may wish to increase target time to 69.7s. bench_startup/Next.js canary Turbo RCC/1000 modules time: [4.7222 s 4.7508 s 4.7790 s] ``` #### `pr`: ``` Benchmarking bench_startup/Next.js canary Turbo SSR/1000 modules: Warming up for 3.0000 s Warning: Unable to complete 10 samples in 60.0s. You may wish to increase target time to 66.2s. bench_startup/Next.js canary Turbo SSR/1000 modules time: [4.1175 s 4.1310 s 4.1496 s] Found 1 outliers among 10 measurements (10.00%) 1 (10.00%) high severe Benchmarking bench_startup/Next.js canary Turbo RSC/1000 modules: Warming up for 3.0000 s Warning: Unable to complete 10 samples in 60.0s. You may wish to increase target time to 63.7s. bench_startup/Next.js canary Turbo RSC/1000 modules time: [4.0401 s 4.0714 s 4.1105 s] Found 1 outliers among 10 measurements (10.00%) 1 (10.00%) high mild Benchmarking bench_startup/Next.js canary Turbo RCC/1000 modules: Warming up for 3.0000 s Warning: Unable to complete 10 samples in 60.0s. You may wish to increase target time to 70.2s. bench_startup/Next.js canary Turbo RCC/1000 modules time: [4.6696 s 4.6900 s 4.7107 s] Benchmarking bench_startup/Next.js 14 Turbo SSR/1000 modules: Warming up for 3.0000 s Warning: Unable to complete 10 samples in 60.0s. You may wish to increase target time to 63.9s. ``` --------- Co-authored-by: Benjamin Woodruff <benjamin.woodruff@vercel.com>
ForsakenHarmony
pushed a commit
to vercel/next.js
that referenced
this pull request
Jul 29, 2024
### Description If we accept `: String` from a function, invoking the function needs one owned `String` and it means allocation even if the value isn't changed. But with this PR, functions now accept `RcStr`, which is shared, so invoking the same function with the same value does not involve allocation for `String` . --- I tried using `Arc<String>` in vercel/turborepo#7772, but a team member suggested creating a new type so we can replace underlying implementation easily in the future. I used `ast-grep` with ```yml id: convert-expr-into language: rust rule: kind: function_item all: - has: kind: parameters pattern: $PARAMS - any: - has: kind: visibility_modifier pattern: $VIS - not: has: kind: visibility_modifier - any: - has: kind: function_modifiers pattern: $MOD - not: has: kind: function_modifiers - has: field: return_type pattern: $RET - has: field: body pattern: $BODY - has: kind: identifier pattern: $NAME - follows: kind: attribute_item pattern: '#[turbo_tasks::function]' transform: NEW_PARAMS: replace: replace: 'String' by: 'RcStr' source: $PARAMS fix: $VIS $MOD fn $NAME $NEW_PARAMS -> $RET $BODY ``` ### Performance difference: #### `main`: ``` Benchmarking bench_startup/Next.js canary Turbo SSR/1000 modules: Warming up for 3.0000 s Warning: Unable to complete 10 samples in 60.0s. You may wish to increase target time to 65.6s. bench_startup/Next.js canary Turbo SSR/1000 modules time: [4.1476 s 4.1625 s 4.1752 s] Benchmarking bench_startup/Next.js canary Turbo RSC/1000 modules: Warming up for 3.0000 s Warning: Unable to complete 10 samples in 60.0s. You may wish to increase target time to 63.5s. bench_startup/Next.js canary Turbo RSC/1000 modules time: [4.0396 s 4.0673 s 4.0956 s] Benchmarking bench_startup/Next.js canary Turbo RCC/1000 modules: Warming up for 3.0000 s Warning: Unable to complete 10 samples in 60.0s. You may wish to increase target time to 69.7s. bench_startup/Next.js canary Turbo RCC/1000 modules time: [4.7222 s 4.7508 s 4.7790 s] ``` #### `pr`: ``` Benchmarking bench_startup/Next.js canary Turbo SSR/1000 modules: Warming up for 3.0000 s Warning: Unable to complete 10 samples in 60.0s. You may wish to increase target time to 66.2s. bench_startup/Next.js canary Turbo SSR/1000 modules time: [4.1175 s 4.1310 s 4.1496 s] Found 1 outliers among 10 measurements (10.00%) 1 (10.00%) high severe Benchmarking bench_startup/Next.js canary Turbo RSC/1000 modules: Warming up for 3.0000 s Warning: Unable to complete 10 samples in 60.0s. You may wish to increase target time to 63.7s. bench_startup/Next.js canary Turbo RSC/1000 modules time: [4.0401 s 4.0714 s 4.1105 s] Found 1 outliers among 10 measurements (10.00%) 1 (10.00%) high mild Benchmarking bench_startup/Next.js canary Turbo RCC/1000 modules: Warming up for 3.0000 s Warning: Unable to complete 10 samples in 60.0s. You may wish to increase target time to 70.2s. bench_startup/Next.js canary Turbo RCC/1000 modules time: [4.6696 s 4.6900 s 4.7107 s] Benchmarking bench_startup/Next.js 14 Turbo SSR/1000 modules: Warming up for 3.0000 s Warning: Unable to complete 10 samples in 60.0s. You may wish to increase target time to 63.9s. ``` --------- Co-authored-by: Benjamin Woodruff <benjamin.woodruff@vercel.com>
ForsakenHarmony
pushed a commit
to vercel/next.js
that referenced
this pull request
Aug 1, 2024
### Description If we accept `: String` from a function, invoking the function needs one owned `String` and it means allocation even if the value isn't changed. But with this PR, functions now accept `RcStr`, which is shared, so invoking the same function with the same value does not involve allocation for `String` . --- I tried using `Arc<String>` in vercel/turborepo#7772, but a team member suggested creating a new type so we can replace underlying implementation easily in the future. I used `ast-grep` with ```yml id: convert-expr-into language: rust rule: kind: function_item all: - has: kind: parameters pattern: $PARAMS - any: - has: kind: visibility_modifier pattern: $VIS - not: has: kind: visibility_modifier - any: - has: kind: function_modifiers pattern: $MOD - not: has: kind: function_modifiers - has: field: return_type pattern: $RET - has: field: body pattern: $BODY - has: kind: identifier pattern: $NAME - follows: kind: attribute_item pattern: '#[turbo_tasks::function]' transform: NEW_PARAMS: replace: replace: 'String' by: 'RcStr' source: $PARAMS fix: $VIS $MOD fn $NAME $NEW_PARAMS -> $RET $BODY ``` ### Performance difference: #### `main`: ``` Benchmarking bench_startup/Next.js canary Turbo SSR/1000 modules: Warming up for 3.0000 s Warning: Unable to complete 10 samples in 60.0s. You may wish to increase target time to 65.6s. bench_startup/Next.js canary Turbo SSR/1000 modules time: [4.1476 s 4.1625 s 4.1752 s] Benchmarking bench_startup/Next.js canary Turbo RSC/1000 modules: Warming up for 3.0000 s Warning: Unable to complete 10 samples in 60.0s. You may wish to increase target time to 63.5s. bench_startup/Next.js canary Turbo RSC/1000 modules time: [4.0396 s 4.0673 s 4.0956 s] Benchmarking bench_startup/Next.js canary Turbo RCC/1000 modules: Warming up for 3.0000 s Warning: Unable to complete 10 samples in 60.0s. You may wish to increase target time to 69.7s. bench_startup/Next.js canary Turbo RCC/1000 modules time: [4.7222 s 4.7508 s 4.7790 s] ``` #### `pr`: ``` Benchmarking bench_startup/Next.js canary Turbo SSR/1000 modules: Warming up for 3.0000 s Warning: Unable to complete 10 samples in 60.0s. You may wish to increase target time to 66.2s. bench_startup/Next.js canary Turbo SSR/1000 modules time: [4.1175 s 4.1310 s 4.1496 s] Found 1 outliers among 10 measurements (10.00%) 1 (10.00%) high severe Benchmarking bench_startup/Next.js canary Turbo RSC/1000 modules: Warming up for 3.0000 s Warning: Unable to complete 10 samples in 60.0s. You may wish to increase target time to 63.7s. bench_startup/Next.js canary Turbo RSC/1000 modules time: [4.0401 s 4.0714 s 4.1105 s] Found 1 outliers among 10 measurements (10.00%) 1 (10.00%) high mild Benchmarking bench_startup/Next.js canary Turbo RCC/1000 modules: Warming up for 3.0000 s Warning: Unable to complete 10 samples in 60.0s. You may wish to increase target time to 70.2s. bench_startup/Next.js canary Turbo RCC/1000 modules time: [4.6696 s 4.6900 s 4.7107 s] Benchmarking bench_startup/Next.js 14 Turbo SSR/1000 modules: Warming up for 3.0000 s Warning: Unable to complete 10 samples in 60.0s. You may wish to increase target time to 63.9s. ``` --------- Co-authored-by: Benjamin Woodruff <benjamin.woodruff@vercel.com>
ForsakenHarmony
pushed a commit
to vercel/next.js
that referenced
this pull request
Aug 14, 2024
# Turbopack * vercel/turborepo#8272 <!-- Donny/강동윤 - feat: Update `swc_core` to `v0.92.8` --> * vercel/turborepo#8262 <!-- Alexander Lyon - add crate to calculate prehashes --> * vercel/turborepo#8174 <!-- Tobias Koppers - use prehash to avoid rehashing the key in the task cache --> * vercel/turborepo#7674 <!-- Alexander Lyon - [turbo trace] add ability to filter by value and occurences --> * vercel/turborepo#8287 <!-- Donny/강동윤 - feat: Update `swc_core` to `v0.92.10` --> * vercel/turborepo#8037 <!-- Alexander Lyon - create turbo-static for compile time graph analysis --> * vercel/turborepo#8293 <!-- Will Binns-Smith - Sync Cargo.lock with Next.js --> * vercel/turborepo#8239 <!-- Benjamin Woodruff - Reduce amount of code generated by ValueDebugFormat --> * vercel/turborepo#8304 <!-- Benjamin Woodruff - Minor optimizations to the codegen of TaskFnInputFunction --> * vercel/turborepo#8221 <!-- Donny/강동윤 - perf: Introduce `RcStr` --> ### What? I tried using `Arc<String>` in vercel/turborepo#7772, but a team member suggested creating a new type so we can replace underlying implementation easily in the future. ### Why? To reduce memory usage. ### How? Closes PACK-2776
ForsakenHarmony
pushed a commit
to vercel/next.js
that referenced
this pull request
Aug 15, 2024
* vercel/turborepo#8272 <!-- Donny/강동윤 - feat: Update `swc_core` to `v0.92.8` --> * vercel/turborepo#8262 <!-- Alexander Lyon - add crate to calculate prehashes --> * vercel/turborepo#8174 <!-- Tobias Koppers - use prehash to avoid rehashing the key in the task cache --> * vercel/turborepo#7674 <!-- Alexander Lyon - [turbo trace] add ability to filter by value and occurences --> * vercel/turborepo#8287 <!-- Donny/강동윤 - feat: Update `swc_core` to `v0.92.10` --> * vercel/turborepo#8037 <!-- Alexander Lyon - create turbo-static for compile time graph analysis --> * vercel/turborepo#8293 <!-- Will Binns-Smith - Sync Cargo.lock with Next.js --> * vercel/turborepo#8239 <!-- Benjamin Woodruff - Reduce amount of code generated by ValueDebugFormat --> * vercel/turborepo#8304 <!-- Benjamin Woodruff - Minor optimizations to the codegen of TaskFnInputFunction --> * vercel/turborepo#8221 <!-- Donny/강동윤 - perf: Introduce `RcStr` --> I tried using `Arc<String>` in vercel/turborepo#7772, but a team member suggested creating a new type so we can replace underlying implementation easily in the future. To reduce memory usage. Closes PACK-2776
ForsakenHarmony
pushed a commit
to vercel/next.js
that referenced
this pull request
Aug 16, 2024
* vercel/turborepo#8272 <!-- Donny/강동윤 - feat: Update `swc_core` to `v0.92.8` --> * vercel/turborepo#8262 <!-- Alexander Lyon - add crate to calculate prehashes --> * vercel/turborepo#8174 <!-- Tobias Koppers - use prehash to avoid rehashing the key in the task cache --> * vercel/turborepo#7674 <!-- Alexander Lyon - [turbo trace] add ability to filter by value and occurences --> * vercel/turborepo#8287 <!-- Donny/강동윤 - feat: Update `swc_core` to `v0.92.10` --> * vercel/turborepo#8037 <!-- Alexander Lyon - create turbo-static for compile time graph analysis --> * vercel/turborepo#8293 <!-- Will Binns-Smith - Sync Cargo.lock with Next.js --> * vercel/turborepo#8239 <!-- Benjamin Woodruff - Reduce amount of code generated by ValueDebugFormat --> * vercel/turborepo#8304 <!-- Benjamin Woodruff - Minor optimizations to the codegen of TaskFnInputFunction --> * vercel/turborepo#8221 <!-- Donny/강동윤 - perf: Introduce `RcStr` --> I tried using `Arc<String>` in vercel/turborepo#7772, but a team member suggested creating a new type so we can replace underlying implementation easily in the future. To reduce memory usage. Closes PACK-2776
2 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
If we accept
: String
from a function, invoking the function needs one ownedString
and it means allocation even if the value isn't changed. But with this PR, functions now acceptRcStr
, which is shared, so invoking the same function with the same value does not involve allocation forString
.I tried using
Arc<String>
in #7772, but a team member suggested creating a new type so we can replace underlying implementation easily in the future.I used
ast-grep
withPerformance difference:
main
:pr
: